package com.briup.day05;

import java.util.Scanner;

/**
 * @author ThinkBook
 */
public class Test05_Switch {
    public static boolean isRunYear(int y){
        if((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) {
            return true;
        }
            return false;

    }
//    从键盘录入年份月份输出该月有多少天
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println("请录入年份: ");
    int year = sc.nextInt();
    int month = sc.nextInt();
    switch (month){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            System.out.println("31天");
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            System.out.println("30天");
            break;
        case 2:
            if(isRunYear(year)){
                System.out.println("29天");
            }else{
                System.out.println("28天");
            }
            break;
        default:
            System.out.println("月份有误!");
            break;
    }
}
    //分支语句基础案例
    public static void main01(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请录入工作模式: ");
        String mode = sc.nextLine();

        switch (mode) {
            case "默认":
                System.out.println("默认模式开启");
                break;
            case "手动":
                System.out.println("手动模式开启");
                break;
            case "节能":
                System.out.println("节能模式开启");
                break;
            default:
                System.out.println("其他情况");
                break;
        }
        System.out.println("after switch语句, 往后运行！");
    }
}
